# 2. set up the stable repository $sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo Loaded plugins: fastestmirror, langpacks adding repo from: https://download.docker.com/linux/centos/docker-ce.repo grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo repo saved to /etc/yum.repos.d/docker-ce.repo
# 3. install docker $ sudo yum install docker-ce Loaded plugins: fastestmirror, langpacks docker-ce-stable | 2.9 kB 00:00:00 docker-ce-stable/x86_64/primary_db | 4.8 kB 00:00:00 Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package docker-ce.x86_64 0:17.03.1.ce-1.el7.centos will be installed --> Processing Dependency: docker-ce-selinux >= 17.03.1.ce-1.el7.centos for package: docker-ce-17.03.1.ce-1.el7.centos.x86_64 --> Processing Dependency: libcgroup for package: docker-ce-17.03.1.ce-1.el7.centos.x86_64 --> Processing Dependency: libseccomp.so.2()(64bit) for package: docker-ce-17.03.1.ce-1.el7.centos.x86_64 --> Running transaction check ---> Package docker-ce-selinux.noarch 0:17.03.1.ce-1.el7.centos will be installed --> Processing Dependency: policycoreutils-python for package: docker-ce-selinux-17.03.1.ce-1.el7.centos.noarch ---> Package libcgroup.x86_64 0:0.41-11.el7 will be installed ---> Package libseccomp.x86_64 0:2.3.1-2.el7 will be installed --> Running transaction check ---> Package policycoreutils-python.x86_64 0:2.5-11.el7_3 will be installed --> Processing Dependency: setools-libs >= 3.3.8-1 for package: policycoreutils-python-2.5-11.el7_3.x86_64 --> Processing Dependency: libsemanage-python >= 2.5-5 for package: policycoreutils-python-2.5-11.el7_3.x86_64 --> Processing Dependency: audit-libs-python >= 2.1.3-4 for package: policycoreutils-python-2.5-11.el7_3.x86_64 --> Processing Dependency: python-IPy for package: policycoreutils-python-2.5-11.el7_3.x86_64 --> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycoreutils-python-2.5-11.el7_3.x86_64 --> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycoreutils-python-2.5-11.el7_3.x86_64 --> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycoreutils-python-2.5-11.el7_3.x86_64 --> Processing Dependency: checkpolicy for package: policycoreutils-python-2.5-11.el7_3.x86_64 --> Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-python-2.5-11.el7_3.x86_64 --> Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-python-2.5-11.el7_3.x86_64 --> Running transaction check ---> Package audit-libs-python.x86_64 0:2.6.5-3.el7_3.1 will be installed ---> Package checkpolicy.x86_64 0:2.5-4.el7 will be installed ---> Package libsemanage-python.x86_64 0:2.5-5.1.el7_3 will be installed ---> Package python-IPy.noarch 0:0.75-6.el7 will be installed ---> Package setools-libs.x86_64 0:3.3.8-1.1.el7 will be installed --> Finished Dependency Resolution
Dependencies Resolved
===================================================================================================================== Package Arch Version Repository Size ===================================================================================================================== Installing: docker-ce x86_64 17.03.1.ce-1.el7.centos docker-ce-stable 19 M Installing for dependencies: audit-libs-python x86_64 2.6.5-3.el7_3.1 update 70 k checkpolicy x86_64 2.5-4.el7 base 290 k docker-ce-selinux noarch 17.03.1.ce-1.el7.centos docker-ce-stable 28 k libcgroup x86_64 0.41-11.el7 base 65 k libseccomp x86_64 2.3.1-2.el7 base 56 k libsemanage-python x86_64 2.5-5.1.el7_3 update 104 k policycoreutils-python x86_64 2.5-11.el7_3 update 445 k python-IPy noarch 0.75-6.el7 base 32 k setools-libs x86_64 3.3.8-1.1.el7 base 612 k
# 5. verify docker $ sudo docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 78445dd45222: Pull complete Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7 Status: Downloaded newer image for hello-world:latest
Hello from Docker! This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal.
To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID: https://cloud.docker.com/
For more examples and ideas, visit: https://docs.docker.com/engine/userguide/
2. docker非root配置
1 2 3 4 5 6 7 8 9 10 11
# 查看是否存在docker用户组 $ cat /etc/group | grep docker
# 如果不存在docker用户组,则创建 $ sudo groupadd docker
# 添加当前用户到docker组中 $ sudo gpasswd -a ${USER} docker